package cn.tedu.redissondemo;

import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@MapperScan("cn.tedu.redissondemo.mapper")
@SpringBootApplication
public class RedissondemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(RedissondemoApplication.class, args);
    }
    @Bean
    public Redisson redisson(){
        //此为单机模式
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.64.150:6379").setDatabase(1);
        return (Redisson)Redisson.create(config);
    }

    //@Bean
    //public Redisson redisson(){
    //    //此为集群模式
    //    Config config = new Config();
    //    config.useClusterServers().addNodeAddress("redis://192.168.126.129:7000","redis://192.168.126.129:7001","redis://192.168.126.129:7002","redis://192.168.126.129:7003","redis://192.168.126.129:7004","redis://192.168.126.129:7005");
    //    return (Redisson)Redisson.create(config);
    //}
}
